import { createRouter, createWebHistory } from 'vue-router'
import HelloWorld from '../components/HelloWorld.vue'
import myindex from '../components/myindex.vue'


const routes = [{
        path: '/h',
        name: 'HelloWorld',
        component: HelloWorld
    }, {
        path: '/',
        name: 'index',
        component: myindex
    },
    // 其他路由...  
]

const router = createRouter({
    history: createWebHistory(""),
    routes
})

// router.beforeEach((to, from, next) => {
//     var reslist = ['/login', '/register', '/home']
//     if (reslist.indexOf(to.path) == -1) {
//         var token = localStorage.getItem('token')
//         token = 123
//         if (token) {
//             //验证是否在权限列表中
//             var menulist = localStorage.getItem('mpromition')
//             if (menulist) {
//                 var mlist = JSON.parse(menulist)
//                 if (mlist.indexOf(to.path) >= 0) {
//                     next()
//                 } else {
//                     alert("无权访问此页面")
//                     next({ "name": 'Login' })
//                 }
//             } else {
//                 alert("无权访问")
//             }

//         } else {
//             next({ "name": 'Login' })
//         }
//     }
//     next()
// })



export default router